import { defineStore } from "pinia";

// 航线数据存储：保存/加载航线
// 航线结构：{ id, name, points: [{lon,lat,height}], createdAt }
export const useAirRoutesStore = defineStore("airRoutes", {
  state: () => ({ routes: [] }),
  persist: true,
  actions: {
    saveRoute(route) {
      const idx = this.routes.findIndex((r) => r.id === route.id);
      if (idx >= 0) this.routes[idx] = route; else this.routes.push(route);
    },
    removeRoute(id) {
      this.routes = this.routes.filter((r) => r.id !== id);
    },
  },
});




